package cur.nature.framework.mvc.http;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

@Data
@Schema(description = "返回值")
public final class ResponseObject<T> {
    @Schema(description = "状态代码，200:正常，其它异常")
    private Integer status = 200;//200:正常，其它异常
    @Schema(description = "异常信息")
    private String error="";
    @Schema(description = "数据")
    private Object data;
//    private String clazz_$ = "cur.base.bean.ResponeObject";


    public ResponseObject() { }
    public ResponseObject(Object data) { this.data = data; }

    public static ResponseObject success(Object data) {
        return new ResponseObject(data);
    }
    public static ResponseObject bizException(String message){
        ResponseObject responeObject = new ResponseObject();
        responeObject.setStatus(300);
        responeObject.setError(message);
        return responeObject;
    }

    public static ResponseObject validateException(String message){
        ResponseObject responeObject = new ResponseObject();
        responeObject.setStatus(400);
        responeObject.setError(message);
        return responeObject;
    }

    public static ResponseObject systemErr(String message){
        ResponseObject responeObject = new ResponseObject();
        responeObject.setStatus(500);
        responeObject.setError(message);
        return responeObject;
    }

    public static ResponseObject systemErr(int status, String message){
        ResponseObject responeObject = new ResponseObject();
        responeObject.setStatus(500);
        responeObject.setError(message);
        return responeObject;
    }

    public static ResponseObject unAuthorizeErr(String message){
        ResponseObject responeObject = new ResponseObject();
        responeObject.setStatus(401);
        responeObject.setError(message);
        return responeObject;
    }

}
